/* ----------------------------------------------------------------------
*
* Copyright (C) 2024 XiaoFei. All rights reserved.
*
* $file:        XiaoFei_BasicMath.h
* $Date:        03-October-2024
* $Revision:    V1.2
* $Project:     XiaoFei DSP Library
*
* -------------------------------------------------------------------- */

#ifndef __XiaoFei_BasicMath_H
#define __XiaoFei_BasicMath_H

#ifndef My_ERROR
#define My_ERROR                    0.00000001
#endif
#ifndef My_PI
#define My_PI                       3.14159265
#endif
#ifndef My_EXP_2
#define My_EXP_2                    7.38905609
#endif
#ifndef My_EXP_5
#define My_EXP_5                    148.41315915
#endif
#ifndef My_LOG_2
#define My_LOG_2                    0.69314718
#endif
#ifndef My_LOG_10
#define My_LOG_10                   2.30258509
#endif

#ifndef ResStatus_TypeDef_def
#define ResStatus_TypeDef_def
typedef enum
{ 
    Error       = 0x00,         /*!< The calculation failed */
    Success     = 0x01          /*!< The calculation was successful */
}ResStatus_TypeDef;
#endif

#ifndef ResMothod_TypeDef_def
#define ResMothod_TypeDef_def
typedef enum
{ 
    Lagrange    = 0x00,         /*!< Calculations based on Lagrangian interpolation */
    Pade        = 0x01,         /*!< Calculations based on Pade approximations */
    Taylor      = 0x02,         /*!< Calculations based on Taylor series */
    Bernoulli   = 0x03          /*!< Calculations based on Bernoulli split-part approximation */
}ResMothod_TypeDef;
#endif

/* 
* @function:    My_RealSin
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Sinusoidal function.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealSin(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealCos
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Cosine function.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealCos(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealTan
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Tangent function.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealTan(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealSec
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Secant function.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealSec(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealCsc
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Cosecant function.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealCsc(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealCot
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Cotangent function.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealCot(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealExp
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Exponential functions.
*                                       This parameter can be selected from -20 to 20.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealExp(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealLog
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Logarithmic functions.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealLog(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealArctan
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Arctangent function.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealArctan(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealSqrt
* @parameter:   [in]    Mothod          The approximation method used for the calculation.
*                                       This parameter can be any value of @ref ResMothod_TypeDef.
* @parameter:   [in]    *input          A pointer to the argument of a Square root.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [in]    order           The order of the function approximation.
*                                       This parameter can be any integer from 4 to 8.
* @parameter:   [out]   *output         The result of the calculation your mothod.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealSqrt(ResMothod_TypeDef Mothod, double* input, unsigned int order, double* output);

/* 
* @function:    My_RealAbs
* @parameter:   [in]    *input          A pointer to the argument of a absolute.
*                                       This parameter can be selected in its definition domain.
* @parameter:   [out]   *output         The result of the function.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_RealAbs(double* input, double* output);

#endif

